{% extends 'blog_article/base.html' %}
{% load blog_tag %}
{% block title %}
 {{ post.title }}
{% endblock %}
{% block content %}
<h1>{{ post.title }}</h1>
<p class="date">
    published {{ post.publish }} by {{ post.author }}
</p>
    {{ post.body|my_markdown }}
    <p><a href="{% url 'share' post.id %}">share this post</a></p>
    <h2>similar posts</h2>
    {% for similar_post in similar_posts %}
        <p>
            <a href="{{ post.get_absolute_url }}">{{ post.title }}</a>
        </p>
        {% empty %}
        there are no posts yet
    {% endfor %}

    {% with comments.count as total_comments %}
        <h2>
        {{ total_comments }} comment{{ total_comments|pluralize }}
        </h2>
    {% endwith %}
    {% for comment in comments %}
        <div class="comment">
        <p class="info">
            comment {{ forloop.counter  }} by {{ comment.name }}
        </p>
        {{ comment.body|linebreaks }}
        </div>
        {% empty %}
        <p>there are no comment</p>
    {% endfor %}
    {% if new_comment %}
        <h2>your comment has been added</h2>
        {% else %}
        <h2>add a new comment</h2>
        <form action="" method="post">
        {{ comment_form.as_p }}
        {% csrf_token %}
            <input type="submit" value="add comment">
        </form>
    {% endif %}
{% endblock %}

